package com.wpre.springconfigs.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-10-27
 * Time: 22:10
 */
@RestController
@RequestMapping("/test")
public class ConfController {

    @Value("${my.key}")
    private String myKey;

    @Value("${my.key2}")
    private Integer myKey2;

    @Value("${my.key3}")
    private Boolean myKey3;

    @Autowired
    public Student student;


    @RequestMapping("/read")
    public String readValue1() {
        return "从配置文件中读取信息" + myKey;
    }


    @PostConstruct
    public void readValue2() {
        System.out.println("从配置文件中读取配置信息" + myKey);
    }

    @PostConstruct
    public void readValue3() {
        System.out.println("从配置文件中读取配置信息" + myKey2);
    }




    @PostConstruct
    public void readValue4() {
        System.out.println("从配置文件中读取配置信息" + myKey3);
    }

    @RequestMapping("/readStudent")
    public String read(){

        return student.toString();
    }

}
